package ru.msu.cmc.sp.oberon2;

import java.util.Vector;
import ru.msu.cmc.sp.oberon2.*;

public class ProcedureType extends Symbol implements Type
{
	public Vector<Symbol> params = new Vector<Symbol>();
	Type retType = null;
	
	public ProcedureType(String name, Type type, Scope parent)
	{
		super(name, type, parent);
	}
	
	public void addParam(Symbol s) {
		params.add(s);
	}
	
	boolean equalParams(Vector<Symbol> v) {
		int count = params.size();
		if (count != v.size()) {
			return false;
		}
		for (int i = 0; i < count; ++i) {
			Symbol self = params.elementAt(i);
			Symbol test = v.elementAt(i);
			
			if (!self.type.equals(test.type) ||
				self.constant != test.constant) {
				return false;
			}
		}
		return true;
	}
	public int getTypeIndex() {
		return 0;
	}
	public boolean isInt() {
		return false;
	}
	public boolean isReal() {
		return false;
	}
	public boolean isNumber() {
		return false;
	}
	public boolean isString() {
		return false;
	}
	public boolean equals(Object t) {
		if (t instanceof ProcedureType) {
			if (equalParams(((ProcedureType)t).params)) {
				return true;
			}
		}
		return false;
	}
}
